"""
@Date:2022/8/9
@author:Jingyu
@Description：长春安全-安全 新建Demo
@other：
"""
import time

from selenium.webdriver.common.by import By

from frameworkTest.FrameworkByRead import FrameworkByRead
from frameworkTest.SuperFramwork import SuperFramwork


class FrameworkByAdd(FrameworkByRead,SuperFramwork):
    # 新增
    def add(self,driver,title):
        driver.find_element(By.XPATH,
                            '/html/body/div[1]/section/section/section/main/div/div[2]/div/div[1]/div/div/div/span[1]/button').click()
        driver.find_element_by_id("sfgno").send_keys(title['sfgno'])
        driver.find_element_by_id("sfgname").send_keys(title['sfgname'])
        # driver.find_element_by_id("deffective") #
        print(title['deffective'])
        driver.find_element(By.XPATH,
                            '//*[@id="deffective"]/div/input').click()
        driver.find_element(By.XPATH,
                            # '/html/body/div[6]/div/div/div/div/div[1]/div/input').send_keys(title['deffective'])
                            '/html/body/div[4]/div/div/div/div/div[1]/div/input').send_keys('2022-08-10')

    def titleOption(self,driver,title):
        print('demo')

    def liReadByOption(self,driver,xpath,ulXpath,text):
        time.sleep(1)
        driver.find_element(By.XPATH,xpath).click()
        time.sleep(2)
        ul = driver.find_element(By.XPATH, ulXpath)
        time.sleep(2)
        li_list = ul.find_elements_by_xpath('li')
        for i in li_list:
            print(i.text)
            if i.text == text:
                i.click()
        time.sleep(1)

    def save(self,driver,title):
        driver.find_element(By.XPATH,title['save']).click()
        time.sleep(3)
